﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CapaNegocio;
using System.Text;

namespace Biblioteca
{
    public partial class RegistrarSocio : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnRegistrar_Click(object sender, EventArgs e)
        {          
            if (Validar())
            {
                if (Controladora.RegistrarSocio(Convert.ToInt32(txtDni.Text),txtNombre.Text,txtMail.Text, txtNomUsuario.Text,txtPass.Text ))
                {
                      ScriptManager.RegisterStartupScript(this, this.GetType(), "Registracion exitosa", "alert(' La registracion ha sido exitosa ');", true);
                    Response.Redirect("Default.aspx");
                }
                else
                   {
                       ScriptManager.RegisterStartupScript(this, this.GetType(), "Error Registracion", "alert(' Ha ocurrido un error en la registracion, por favor vuelva a intentarlo mas tarde');", true);
                }
            }
        }




        private bool Validar()
        {
            bool respu = true;

            if (txtDni.Text.Length == 0 || txtNombre.Text.Length == 0 || txtMail.Text.Length == 0 || txtNomUsuario.Text.Length == 0 || txtPass.Text.Length == 0)
            {
                respu = false;             
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Debe completar todos los campos", "alert(' Debe completar todos los campos ');", true);
                
                
            }
            return respu;
        }









    }
}
